 /*****************************************************************
 * created by lei.he on 2020/07/28 for mongodb connection file
 *****************************************************************/

//  引入mongoose包
const mongo = require('mongoose');

// 引入config的配置文件
const {MONGDB_PATH} = require('../config');

// 连接数据库
mongo.connect(MONGDB_PATH);

//连接数据库成功或者失败返回日志
const {HandleLogs} = require('../utils');
mongo.connection.on('connected',() =>{
    HandleLogs('mongodb connected')
})
mongo.connection.on('error',(e) =>{
    HandleLogs('mongodb error',e);
})

// 导出mongo对象
module.exports =  mongo